<?php
header("Content-Type:text/html; charset=utf-8");

$this->load->view("header");
?>

<script type="text/javascript">
function modify(control, target, property) {

	var evt = (event) ? event : ((window.event) ? window.event : "");
	var key = evt.keyCode ? evt.keyCode : evt.which;
	if(key==13 ) {

		var temp = document.getElementById(control);
		if (temp.defaultValue != temp.value) {

			var r=confirm("确认修改吗?");
			if (r==true) {
				window.location="<?php get_config('base_url'); ?>?type="+<?php echo $type; ?>+"&protocal=1109"+"&target="+target+"&property="+property+"&new_value="+temp.value;
			}
		}
	}
}
function delete_period(target) {
	var r=confirm("确认删除吗?");
	if (r==true) {
		window.location="<?php get_config('base_url'); ?>?type="+<?php echo $type; ?>+"&protocal=1110"+"&target="+target;
	}
}
function enable_input(control) {
	var temp = document.getElementById(control);
	temp.readOnly = false;
}
</script>


<h2 style="background-color:red;"><?php echo $msg; ?></h2>


<table id="t1" width="600" border="1" cellpadding="5">

	<tr>
		<th scope="col">period</th>
		<th scope="col">start time</th>
		<th scope="col">end time</th>
		<th scope="col">Action</th>
	</tr>

	<?php foreach ($period_list as $aPeriod){ ?>
	<tr>
		<td><input type="text" readonly id="period_<?php echo $aPeriod->period; ?>" value="<?php echo $aPeriod->period; ?>" style="width:100%" onClick="enable_input('period_<?php echo $aPeriod->period; ?>')" onkeypress="modify('period_<?php echo $aPeriod->period; ?>', '<?php echo $aPeriod->period; ?>', 'period')" /></td>
		<td><input type="text" readonly id="start_time_<?php echo $aPeriod->period; ?>" value="<?php echo $aPeriod->start_time; ?>" style="width:100%" onClick="enable_input('start_time_<?php echo $aPeriod->period; ?>')" onkeypress="modify('start_time_<?php echo $aPeriod->period; ?>', '<?php echo $aPeriod->period; ?>', 'start_time')" /></td>
		<td><input type="text" readonly id="end_time_<?php echo $aPeriod->period; ?>" value="<?php echo $aPeriod->end_time; ?>" style="width:100%" onClick="enable_input('end_time_<?php echo $aPeriod->period; ?>')" onkeypress="modify('end_time_<?php echo $aPeriod->period; ?>', '<?php echo $aPeriod->period; ?>', 'end_time')" /></td>
		<td width="50" align="left"><a href="#"
			onClick="delete_period(<?php echo $aPeriod->period;?>)">Delete</a>
		</td>
	</tr>

	<?php }?>
</table>

<form id="form" method="post" action="<?php get_config('base_url'); ?>?type=<?php echo $type; ?>&protocal=1103">
	<table id="t1" width="600" border="1" cellpadding="5">
	<tr>
		<td><input type="text" name="period" style="width:100%" /></td>
		<td><input type="text" name="start_time" style="width:100%" /></td>
		<td><input type="text" name="end_time" style="width:100%" /></td>
		<td><input type="submit" name="submit" value="添加" style="width:100%" /></td>
	</tr>
	</table>
</form>

<?php
$this->load->view("footer");
?>